<template>
  <el-container class="setting_shopping-mall_inventory-set">
    <el-main>
      <div class="wrapper-box">
        <div class="dis">
          <div class="setting-content">
            <el-form ref="inventoryForm" :model="sensitiveWordParams">
              <el-card shadow="never" class="cardInfo">
                <div class="bg-white-panel">基本参数设置</div>
                <div class="dis al_item">
                  <div class="nav-item">
                    <div class="dis al_item dis_ju_spb item-header">
                      <div class="cursor flex_1 dis al_item">
                        <el-form-item class="person-center-form-item" label="通知方式：">
                          <el-checkbox-group v-model="sensitiveWordParams.settingBase.notifyChannel" style="margin-left:11rem">
                            <el-checkbox :label="1">短信</el-checkbox>
                            <el-checkbox :label="2">邮件</el-checkbox>
                            <el-checkbox :label="3">企微</el-checkbox>
                          </el-checkbox-group>
                        </el-form-item>
                      </div>
                    </div>
                  </div>
                </div>
              </el-card>
              <el-card shadow="never" class="cardInfo">
                <div class="bg-white-panel">通知对象</div>
                <div class="dis al_item">
                  <div class="nav-item">
                    <div class="dis al_item dis_ju_spb item-header">
                      <div class="cursor flex_1 dis al_item">
                        <el-form-item class="person-center-form-item">
                          <span class="form-item-title">发送人：</span>
                          <el-switch
                            v-model="sensitiveWordParams.settingReceiver.toMsgSender"
                            :active-value="1"
                            :inactive-value="2"
                          />
                          <span class="form-item-title">  (开启后，一旦触发消息将发给发起人)</span>
                        </el-form-item>
                      </div>
                    </div>
                    <div class="dis al_item dis_ju_spb item-header">
                      <div class="cursor flex_1 dis al_item">
                        <el-form-item class="person-center-form-item" style="margin-left: 130px;">
                          <span class="form-item-title">提醒时间段</span>
                          <el-time-picker v-model="sensitiveWordParams.settingReceiver.toMsgSenderTimeBegin" :disabled="sensitiveWordParams.settingReceiver.toMsgSender==1?false:true" :picker-options="{selectableRange: '00:00:00 - 23:59:59'}" placeholder="任意时间点" />
                          <span class="form-item-title">至</span>
                          <el-time-picker v-model="sensitiveWordParams.settingReceiver.toMsgSenderTimeEnd" :disabled="sensitiveWordParams.settingReceiver.toMsgSender==1?false:true" :picker-options="{selectableRange: '00:00:00 - 23:59:59'}" placeholder="任意时间点" />
                        </el-form-item>
                      </div>
                    </div>
                  </div>
                </div>
                <div class="dis al_item">
                  <div class="nav-item">
                    <div class="dis al_item dis_ju_spb item-header">
                      <div class="cursor flex_1 dis al_item">
                        <el-form-item class="person-center-form-item">
                          <span class="form-item-title">管理员：</span>
                          <el-switch
                            v-model="sensitiveWordParams.settingReceiver.toMsgManager"
                            :active-value="1"
                            :inactive-value="2"
                          />
                          <span class="form-item-title">(开启后，一旦触发消息将发给管理员)</span>
                        </el-form-item>
                      </div>
                    </div>
                    <div class="dis al_item dis_ju_spb item-header">
                      <div class="cursor flex_1 dis al_item">
                        <el-form-item class="person-center-form-item" style="margin-left: 130px;">
                          <span class="form-item-title">提醒时间段</span>
                          <el-time-picker v-model="sensitiveWordParams.settingReceiver.toMsgManagerTimeBegin" :disabled="sensitiveWordParams.settingReceiver.toMsgManager==1?false:true" :picker-options="{selectableRange: '00:00:00 - 23:59:59'}" placeholder="任意时间点" />
                          <span class="form-item-title">至</span>
                          <el-time-picker v-model="sensitiveWordParams.settingReceiver.toMsgManagerTimeEnd" :disabled="sensitiveWordParams.settingReceiver.toMsgManager==1?false:true" :picker-options="{selectableRange: '00:00:00 - 23:59:59'}" placeholder="任意时间点" />
                        </el-form-item>
                      </div>
                    </div>
                  </div>
                </div>
              </el-card>
            </el-form>
          </div>
        </div>
      </div>
      <div class="btn-footer">
        <el-button>取消</el-button>
        <el-button type="primary" @click="submit">保存</el-button>
      </div>
    </el-main>
  </el-container>
</template>

<script>
import { sensitiveWordSettingSave, sensitiveWordSettingView } from '@/api/shoppingMall'
export default {
  components: {
  },
  data() {
    return {
      sensitiveWordParams: {
        settingBase: {
          notifyChannel: [1, 3]
        },
        settingReceiver: {
          toMsgSender: 1,
          toMsgSenderTimeBegin: '08:00:00',
          toMsgSenderTimeEnd: '22:00:00',
          toMsgManager: 1,
          toMsgManagerTimeBegin: '08:00:00',
          toMsgManagerTimeEnd: '22:00:00'
        }
      }
    }
  },
  created() {
    this.getSensitiveWordSettingInfo()
  },
  methods: {
    getSensitiveWordSettingInfo() {
      sensitiveWordSettingView().then(res => {
        if (res) {
          if (res.code) {
            this.$message.error(`${res.msg}`)
          } else {
            this.sensitiveWordParams.settingBase = res.settingBase == null ? this.sensitiveWordParams.settingBase : res.settingBase
            this.sensitiveWordParams.settingReceiver = res.settingReceiver == null ? this.sensitiveWordParams.settingReceiver : res.settingReceiver
          }
        }
      })
    },
    submit() {
      this.$confirm('确认要修改配置?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        sensitiveWordSettingSave(this.sensitiveWordParams).then(res => {
          if (res) {
            this.$message.success('保存成功！')
            this.getSensitiveWordSettingInfo()
          }
        })
      })
    }
  }
}
</script>

<style lang="scss">
  .setting_shopping-mall_inventory-set {
    background: #d8d8d8;
    padding: 4px;
    height: 90%;
    border-radius: 3px;
    overflow: auto;
    .clearfix{
      padding:5px;
      padding-top: 0;
      height: 15px;
      display: flex;
      align-items: center;
      >div {
        border: 0px solid #e6ebf5;
        flex-grow: 1;
        width:0;
        margin-right: 20px;
      }
    }
    .dialog-form{
      .el-form-item{
        margin-bottom: 10px !important;
        padding-right: 10px;
      }
    }
    }
    .setting-content {
      width: 100%;
      margin: 0px 0 4px 4px;
      overflow-x: hidden;
      overflow-y: auto;
      border-radius:5px;
      .cardInfo {
          margin-top: 2px;
          padding: 2px;
       }
      .user-center-item {
        box-sizing: border-box;
        cursor: pointer;
        padding-bottom: 10px;
        &.active {
          border: 1px solid #1890ff
        }
      }

    }
    .nav-item {
      font-size: 14px;
      background: #ffffff;
      border: 0px solid #e3e2e5;
      border-radius: 4px;
      margin-bottom: 10px;
      width: 100%;
      display: inline-block;

      &:nth-child(odd) {
        margin-right: 10px;
        font-size: 14px;
        color: #595961;
      }

      .item-header {
        border-radius: 4px 4px 0 0;
        height: 32px;
        line-height: 39px;
        padding: 0 10px 0 5px;
      }

      .item-content {
        padding: 5px 0;
      }
    }
    .person-center-form-item {
      font-size: 14px;
      margin-left: 20px;
      .el-form-item__label, .el-form-item__content, .el-radio__label, .el-button, .el-checkbox .el-checkbox__label {
        font-size: 13px;
      }
      .el-input-number.is-without-controls.el-input__inner{
        width: 20px;
        height: 14px;
      }
      .el-input.is-without-controls.el-input__inner{
        height: 14px;
      }
      .form-item-input{
        min-height: 14px;
        width: 350px;
        font-size: 12px;
      }
      .form-item-title{
        padding-left: 6px;
        padding-right: 6px;
        color: #666;
      }
      .info-setting {
        margin-left: 15px;
        color: #0000FF;
        text-align: right;
        cursor: hand;
      }
      .flex-just{
        vertical-align: middle;
        width: 80px;
      }
    }
    .base-info {
      display: flex;
      .basics-info {
        margin: 0 auto;
      }
    }
    .el-form-item  {
      margin-bottom: 30px;
    }
    .el-col {
      margin-bottom: 0px;
    }
    .noMargin {
      margin-bottom: 0 !important;
    }
  .bg-white-panel {
    padding: 5px;
    font-size: 14px;
    font-weight: bolder;
    border-radius: 4px;
    margin-bottom: 5px;
  }

</style>
